package com.rec.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc;

/**
 * @author 路亚
 * @version 0.1
 * @className Knife4jConfig
 * @description
 * @date 2024/12/4 20:24
 * @since jdk11
 */
@Configuration
@EnableSwagger2WebMvc
public class Knife4jConfig {

    /**
     * 通过knife4j生成接口文档
     * @return
     */
    /*
    * 需要引入<dependency>
                    <groupId>com.github.xiaoymin</groupId>
                    <artifactId>knife4j-spring-boot-starter</artifactId>
                </dependency>
           依赖配置后，访问http://localhost:8080/doc.html即可查看接口文档
    * */
    @Bean
    public Docket docketAdmin() {
        ApiInfo apiInfo = new ApiInfoBuilder()
//                标题
                .title("路亚短剧项目接口文档")
//                版本
                .version("2.0")
//                简介
                .description("路亚短剧项目接口文档")
//                作者
                .contact(new Contact("路亚",null,null))
                .build();
        Docket docket = new Docket(DocumentationType.SWAGGER_2)
                .groupName("管理端接口")
                .apiInfo(apiInfo)
                .select()
//                指定生成接口需要扫描的包
                .apis(RequestHandlerSelectors.basePackage("com.rec.controller"))
                .paths(PathSelectors.any())
                .build();
        return docket;
    }
}
